<?php

namespace App\Http\Validate\Manger;

use App\Http\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class Manger extends BaseValidate
{

    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'code_no' => 'required',
                'username' => 'required|string|min:2|max:20',
                // 'mobile' => 'required',
                'mobile' => ['required', 'regex:/^1[3-9]\d{9}$/'],
                'realname' => 'required|string|min:2|max:20',
                // 'cpd_user_id' => 'required',
                'sys_dpm_id' => 'required',
            ];
            $this->message = [
                'code_no.required' => '编码不能为空',
                'username.required' => '用户名不能为空',
                'username.min' => '用户名长度不能小于2位',
                'username.max' => '用户名长度不能大于20位',
                'mobile.required' => '用户手机号不能为空',
                'mobile.regex'=>'手机号不规范',
                'realname.required' => '姓名不能为空',
                'realname.min' => '姓名长度不能小于2位',
                'realname.max' => '姓名长度不能大于20位',
                'cpd_user_id.required' => '钉钉用户未选择',
                'sys_dpm_id.required' => '系统部门未选择',
            ];
        } else {
            $this->rule = [
                // 'mobile' => 'required',
                'mobile' => ['required', 'regex:/^1[3-9]\d{9}$/'],
                'realname' => 'required|string|min:2|max:20',
                // 'cpd_user_id' => 'required',
                'sys_dpm_id' => 'required',
            ];
            $this->message = [
                'mobile.required' => '用户手机号不能为空',
                'mobile.regex'=>'手机号不规范',
                'realname.required' => '姓名不能为空',
                'realname.min' => '姓名长度不能小于2位',
                'realname.max' => '姓名长度不能大于20位',
                'cpd_user_id.required' => '钉钉用户未选择',
                'sys_dpm_id.required' => '系统部门未选择',
            ];
        }
    }
}
